@extends("home.layouts")

@section("content")
	<div id="content" class="col-sm-9">      <h2>收藏列表</h2>
        <div class="table-responsive">
        <table class="table table-bordered table-hover">
          <thead>
            <tr>
              <td class="text-center">圖像</td>
              <td class="text-left">商品名稱</td>
              <td class="text-left">型號</td>
              <td class="text-right">庫存</td>
              <td class="text-right">單位價格</td>
              <td class="text-right">操作</td>
            </tr>
          </thead>
          <tbody>

          	@foreach($datas as $v)
            <tr>

              <td class="text-center">                
              	<a href="{{ route('goods.show', $v->goods) }}"><img width="50" height="50" src="{{Storage::url($v->goods->cover_img)}}" alt="{{$v->goods->name}}" title="{{$v->goods->name}}">
              	</a>
              </td>

              <td class="text-left"><a href="{{ route('goods.show', $v->goods) }}">{{$v->goods->name}}</a></td>
              <td class="text-left"></td>
              <td class="text-right">{{ $v->goods->stock }}</td>
              <td class="text-right">               
	              <div class="price">
	                   {{ $v->goods->price }}                                
	              </div>
              </td>
              
              <td class="text-right">
                <button type="button"  data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="加入購物車">
                  <i class="fa fa-shopping-cart" data-goods_id="{{$v->goods->id}}"></i>
                </button>
                <a data-url="{{ route('collections.destroy', $v)}}" href="javascript:;" data-toggle="tooltip" title="" class="btn btn-danger" data-original-title="移除"><i class="fa fa-times"></i></a>
              </td>
            </tr>    
            @endforeach

           </tbody>
        </table>
      </div>
           <!--  <div class="buttons clearfix">
        <div class="pull-right"><a href="http://shop14.jccms.cn/index.php?route=account/account" class="btn btn-primary">繼續</a></div>
      </div> -->
      </div>
    <script type="text/javascript">
    	$(function() {
    		$(".btn-danger").on('click', function() {
    			const url = $(this).data('url');
    			$.ajax({
    				url:url,
    				method:'delete',
    				success: res => {
    					location.reload();
    				}
    			});
    		});
    	})
    </script>
@endsection
    	